package com.sky.controller.admin;

import com.sky.dto.DataOverViewQueryDTO;
import com.sky.result.Result;
import com.sky.service.ReportService;
import com.sky.vo.OrderReportVO;
import com.sky.vo.SalesTop10ReportVO;
import com.sky.vo.TurnoverReportVO;
import com.sky.vo.UserReportVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description ReportController
 * @Author zhuzi
 * @Date 2023/10/08
 */
@RequestMapping("/admin/report")
@RequiredArgsConstructor
@RestController
@Slf4j
public class ReportController {

    private final ReportService reportService;

    /**
     * 营业额统计
     *
     * @param data DataOverViewQueryDTO
     * @return Result
     */
    @GetMapping("/turnoverStatistics")
    public Result<TurnoverReportVO> getTurnoverReport(DataOverViewQueryDTO data) {
        log.info("Get DataOverViewQueryDTO: {}", data);
        return Result.success(reportService.getTurnoverReport(data));
    }

    /**
     * 用户统计
     *
     * @param data DataOverViewQueryDTO
     * @return Result
     */
    @GetMapping("/userStatistics")
    public Result<UserReportVO> getUserReport(DataOverViewQueryDTO data) {
        log.info("Get DataOverViewQueryDTO: {}", data);
        return Result.success(reportService.getUserReport(data));
    }

    /**
     * 订单统计
     *
     * @param data DataOverViewQueryDTO
     * @return Result
     */
    @GetMapping("/ordersStatistics")
    public Result<OrderReportVO> getOrderReport(DataOverViewQueryDTO data) {
        log.info("Get DataOverViewQueryDTO: {}", data);
        return Result.success(reportService.getOrderReport(data));
    }

    /**
     * 获取销量前10的商品（包括菜品和套餐）
     *
     * @param data DataOverViewQueryDTO
     * @return Result
     */
    @GetMapping("/top10")
    public Result<SalesTop10ReportVO> getTop10(DataOverViewQueryDTO data) {
        log.info("Get DataOverViewQueryDTO: {}", data);
        return Result.success(reportService.getTop10(data));
    }

}
